﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Ditto.Models.Request>" %>

<div class="summary">

    <div class="image" style="float:left">
        <a href="/Users/Details/<%= Model.RequestingUserID %>"><img class="resized" alt="<%= Model.RequestingUserID %>" src="/Content/users/<%= Model.RequestingUserID %>-small.jpg" /></a>
    </div>

    <div style="float:left">
        <a id="requestinguser" href="/Users/<%: Model.RequestingUserID %>"><%: Model.RequestingUserID%></a>
        <i><%: Model.RequestMessage%></i>
    </div>

    <% if (String.Equals(Model.Item.PostingUserID, Context.User.Identity.Name))
       { %>

               <% if (Model.Item.HasTransactions(Model.RequestingUserID)) { %>
               <div style="float:right;padding:0px;margin:0px">
               see <%: Html.ActionLink("transaction", "RelatedTransaction", "Items", new { id = Model.Item.ItemID }, null)%>
               </div>
               <%}else{ %>
            <div id="dialog_link" style="float:right;padding:0px;margin:0px">
                <%: Html.ActionLink("accept", "AcceptRequest", "Transactions", new { itemID = Model.ItemID, requestingUserID = Model.RequestingUserID }, null)%>
            </div>
            <%} %>
    <%} %>

</div>

<div id="dialog" title="Confirm Acceptance">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 0 0;"></span> You will be agreeing to transact with your friend.</p>
<%--    <p id="dialog_requestinguser"></p>
    <p>If this is correct, click Accept.</p>
    <p>To exit, click Cancel.</p>--%>
</div>

<link rel="stylesheet" type="text/css" href="/Scripts/jquery-ui/jquery-ui-1.8.14.custom.css" />
<script type="text/javascript" src="/Scripts/jquery-ui-1.8.14.custom.min.js"></script>

<script type="text/javascript">
    $(function () {

        // jQuery UI Dialog    
        $('#dialog').dialog({
            autoOpen: false,
            width: 400,
            modal: true,
            resizable: false,
            buttons: {
                "Accept": function () {
                    $.get($('#dialog_link a').attr("href"));
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

        // Dialog Link
        $('#dialog_link a').click(function () {

            $('#dialog').dialog('open');

//            $('#dialog_requestinguser').html($("#requestinguser").val());

            return false;
        });
    });
</script>
